package com.inboyu.admin.domain;

import com.inboyu.listing.domain.StoreId;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 操作日志实体
 */
@Data
public class OperationLogEntity {

    /**
     * 操作日志id
     */
    private OperationLogId operationLogId;

    /**
     * 门店id
     */
    private StoreId storeId;

    /**
     * 员工id
     */
    private StaffId staffId;

    /**
     * 操作人
     */
    private String operator;

    /**
     * 操作行为
     */
    private String operation;

    /**
     * 操作时间
     */
    private LocalDateTime operationTime;

    /**
     * 操作结果详情
     */
    private String operationResult;

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String content;

    /**
     * 操作版本
     */
    private Integer version;

    public static OperationLogEntity init(ContractEntity newContract, ContractEntity oldContract) {
        OperationLogEntity operationLogEntity = new OperationLogEntity();
        operationLogEntity.setStoreId(newContract.getStoreId());
        operationLogEntity.setOperator(newContract.getCreateUser());
        operationLogEntity.setOperationTime(newContract.getCreateTime());
        operationLogEntity.setBusinessType(BusinessType.CONTRACT);
        // todo 处理字段信息对比修改情况
        operationLogEntity.setOperation("");
        operationLogEntity.setOperationResult("");
        return operationLogEntity;
    }
}
